﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ClientRegister
{
    public partial class ListClassForm : Form
    {
        public string IDEmp { set; get; }
        public string NameEmp { set; get; }
        public ListClassForm()
        {
            InitializeComponent();
        }

        SynchronizeData sync = new SynchronizeData();

        private void ListClassForm_Load(object sender, EventArgs e)
        {

            //sync.GetDataForUpdateMethodWithID(sync.ClassTb, sync.updatecol);

            ClassDataProvider load = new ClassDataProvider();
            DataSet ds = load.loadAllInfoClass();
            DataTable dt = ds.Tables[0];
            GridListClass.DataSource = dt;
        }

        private void btnChange_Click(object sender, EventArgs e)
        {
            if (GridListClass.SelectedCells.Count > 0)
            {
                ChangeClassInfoForm changeClass = new ChangeClassInfoForm();
                changeClass.IdClass = GridListClass.CurrentRow.Cells["ID"].Value.ToString();
                changeClass.NameClass = GridListClass.CurrentRow.Cells["NameClass"].Value.ToString();
                changeClass.IdSub = GridListClass.CurrentRow.Cells["IDSubject"].Value.ToString();
                changeClass.IdTeacher = GridListClass.CurrentRow.Cells["IDTearcher"].Value.ToString();
                changeClass.Studyday = GridListClass.CurrentRow.Cells["StudyDay"].Value.ToString();
                changeClass.Room = GridListClass.CurrentRow.Cells["Room"].Value.ToString();
                changeClass.Time = GridListClass.CurrentRow.Cells["Time"].Value.ToString();
                changeClass.Fee = GridListClass.CurrentRow.Cells["Fee"].Value.ToString();
                changeClass.Start = GridListClass.CurrentRow.Cells["StartDate"].Value.ToString();
                changeClass.End = GridListClass.CurrentRow.Cells["EndDate"].Value.ToString();
                changeClass.accept = GridListClass.CurrentRow.Cells["AcceptRegister"].Value.ToString();
                changeClass.note = GridListClass.CurrentRow.Cells["Note"].Value.ToString();
                changeClass.CreateDate = GridListClass.CurrentRow.Cells["CreateDateTime"].Value.ToString();

                changeClass.IDEmp = IDEmp;
                changeClass.NameEmp = NameEmp;
                changeClass.Show();
            }
        }

        private void btnRefresh_Click(object sender, EventArgs e)
        {
           // sync.GetDataForUpdateMethodWithID(sync.ClassTb, sync.updateMethod);

            ClassDataProvider load = new ClassDataProvider();
            DataSet ds = load.loadAllInfoClass();
            DataTable dt = ds.Tables[0];
            GridListClass.DataSource = dt;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
